var path = require('path');
var webpack = require('webpack');
var env = '"production"';
// var env = '"dev"';

module.exports = {
    plugins: [
        new webpack.DefinePlugin({
            'process.env': {
                'NODE_ENV': env
            }
        }),
        new webpack.optimize.UglifyJsPlugin(),
        new webpack.optimize.CommonsChunkPlugin('common.min.js')
    ],
    entry :{
        index : path.resolve(__dirname,'src/js/index/app.js'),
        goods : path.resolve(__dirname,'src/js/goods/app.js'),
        address:path.resolve(__dirname,'src/js/address/app.js'),
        order : path.resolve(__dirname,'src/js/order/app.js'),
        cart : path.resolve(__dirname,'src/js/cart/app.js'),
        seller:path.resolve(__dirname,'src/js/seller/app.js')
    },
    output : {
        path : path.resolve(__dirname,'build/js'),
        filename : '[name]/[name].min.js'
    },
    module : {
        loaders : [
            {//babel loader,以支持ES6语法
                test: /\.js?$/,
                exclude: /node_modules/,
                loader: 'babel',
                query: {
                    presets: ['es2015','react']
                }
            },
            { test: /\.css/, loader: 'style-loader!css-loader'},
            { test: /\.(png|jpg)$/, loader: 'url?limit=8192'}
        ]
    }
}